@extends('backend.layouts.app')

@section('title', $title = '网站加分记录')

@section('breadcrumb')
    <a href="">系统设置</a>
    <a href="">集成系统</a>
    <a href="">{{$title}}</a>
@endsection

@section('content')
    <div class="layui-main">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>{{$title}}</legend>
        </fieldset>
        <form class="layui-form layui-form-pane" method="GET"
              action="{{ route('site.bonus_point_log') }}">
            {{ csrf_field() }}
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">交易时间</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" id="created_at_start" name="created_at_start"
                               placeholder="yyyy-MM-dd HH:mm:ss"
                               value="{{old('created_at_start',$params['created_at_start'])}}">
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" id="created_at_end" name="created_at_end"
                               placeholder="yyyy-MM-dd HH:mm:ss"
                               value="{{old('created_at_end',$params['created_at_end'])}}">
                    </div>
                </div>
                @if(\Auth::user()->type!=2)
                    <div class=" layui-inline">
                        <label class="layui-form-label">网站名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="site_name" width="200" autocomplete="off"
                                   placeholder="请输入网站名称"
                                   class="layui-input" value="{{old('site_name',$params['site_name'])}}">
                        </div>
                    </div>
                @endif
                <div class=" layui-inline">
                    <label class="layui-form-label">平台编号</label>
                    <div class="layui-input-block">
                        <select name="main_game_plat_code" lay-verify="" lay-search="">
                            <option value="">请选择平台编号</option>
                            @foreach($plats as $plat)
                                <option value={{$plat->main_game_plat_code}} @if($params['main_game_plat_code']===$plat->main_game_plat_code) selected @endif>{{$plat->main_game_plat_name}}</option>
                            @endforeach
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">交易单号</label>
                    <div class="layui-input-block">
                        <input type="text" name="transferid" width="200" autocomplete="off"
                               placeholder="请输入交易单号"
                               class="layui-input" value="{{old('transferid',$params['transferid'])}}">
                    </div>
                </div>
                <div class=" layui-inline">
                    <label class="layui-form-label">交易状态</label>
                    <div class="layui-input-block">
                        <select name="status" lay-verify="" lay-search="">
                            <option value="">请选择交易状态</option>
                            <option value=1 @if($params['status']===1) selected @endif>成功</option>
                            <option value=0 @if($params['status']===0) selected @endif>失败</option>
                            <option value=-1 @if($params['status']===-1) selected @endif>未知</option>
                            <option value=2 @if($params['status']===2) selected @endif>取消</option>
                        </select>
                    </div>
                </div>

            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <button class=" layui-btn" lay-submit="" lay-filter="demo1">提交</button>
                </div>
                <div class="layui-inline" style="float: right">
                    <button type="button" class="layui-btn" id="generate-excel">
                        将表格转换为Excel
                    </button>
                </div>
            </div>
        </form>


        <div class="layui-form">
            @if($siteScores->count())
                <table class="layui-table"
                       lay-data="{id:'DeleteTable',totalRow: true,limit:{{$limit+1}}}">
                    <thead>
                    <tr>
                        <th lay-data="{type:'checkbox', fixed: 'left'}">#</th>
                        <th lay-data="{field:'id', width:80, sort: true}">id</th>
                        <th lay-data="{field:'site_username', width:100,  sort: true}">网站名称</th>
                        <th lay-data="{field:'main_game_plat_code', width:100,  sort: true}">平台编号</th>
                        <th lay-data="{field:'rate',  width:100, sort: true}">比率</th>
                        <th lay-data="{field:'recharge_money',width:100,  sort: true}">充值金额</th>
                        <th lay-data="{field:'recharge_score',width:100,  sort: true}">加分</th>
                        <th lay-data="{field:'original',width:200,  sort: true}">变动前的分</th>
                        <th lay-data="{field:'change',width:200,  sort: true, }">变动的分</th>
                        <th lay-data="{field:'before_money',width:100,  sort: true}">前余额</th>
                        <th lay-data="{field:'now_money', width:100, sort: true}">现余额</th>
                        <th lay-data="{field:'player', width:100, sort: true}">操作玩家</th>
                        <th lay-data="{field:'op', width:100, sort: true}">操作类型</th>
                        <th lay-data="{field:'status', width:100, sort: true}">处理状态</th>
                        <th lay-data="{field:'created_at', width:170, sort: true}">创建时间</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($siteScores as $index => $siteScore)
                        <tr>
                            <td></td>
                            <td>{{ $siteScore->id }}</td>
                            <td>{{ $siteScore->Site->username  }}</td>
                            <td>{{ $siteScore->MainGamePlat->main_game_plat_code  }}</td>
                            <td>{{ $siteScore->rate  }}</td>
                            <td>{{ $siteScore->recharge_money  }}</td>
                            <td>{{ $siteScore->recharge_score  }}</td>
                            <td>{{ $siteScore->original  }}</td>
                            <td>{{ $siteScore->change  }}</td>
                            <td>{{ $siteScore->before_money }}</td>
                            <td>{{ $siteScore->now_money  }}</td>
                            <td>{{ $siteScore->Player->username??''  }}</td>
                            <td>{{ $siteScore->getOpType()  }}</td>
                            @if($siteScore->status===1)
                                <td><div class="layui-bg-green" style="text-align: center">{{ $siteScore->getStatus() }}</div></td>
                            @elseif($siteScore->status===0)
                                <td><div class="layui-bg-red" style="text-align: center">{{ $siteScore->getStatus() }}</div></td>
                            @elseif($siteScore->status===-1)
                                <td><div class="layui-bg-orange" style="text-align: center">{{ $siteScore->getStatus() }}</div></td>
                            @elseif($siteScore->status===2)
                                <td><div class="layui-bg-gray" style="text-align: center">{{ $siteScore->getStatus() }}</div></td>
                            @endif
                            <td>{{ $siteScore->created_at  }}</td>
                        </tr>
                    @endforeach
                    <tr>
                        <td></td>
                        <td>总合计：</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td>{{$sumParams['recharge_money']}}</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                    </tbody>
                </table>
                <div id="paginate-render"></div>
            @else
                <br/>
                <blockquote class="layui-elem-quote">暂无数据!</blockquote>
            @endif

        </div>
    </div>

@endsection

@section('scripts')
    @include('backend.layouts._paginate',[ 'count' => $siteScores->total(), 'delBatchUrl'=>'','limit'=>$limit])

    <script type="text/javascript" src="/js/external/jquery-1.8.2.js"></script>
    <script type="text/javascript" src="/js/external/jszip.js"></script>
    <script type="text/javascript" src="/js/external/FileSaver.js"></script>
    <script type="text/javascript" src="/js/scripts/excel-gen.js"></script>
    <script>
        layui.use('laydate', function () {
            var laydate = layui.laydate;

            //日期时间选择器
            laydate.render({
                elem: '#created_at_start'
                , type: 'datetime'
            });

            laydate.render({
                elem: '#created_at_end'
                , type: 'datetime'
            });
        });
    </script>

    <script>
        $(document).ready(function () {
            excel = new ExcelGen({
                "src_id": "myTable",
                "show_header": true
            });
            $("#generate-excel").click(function () {
                excel.generate();
            });
        });


    </script>
@endsection
